package com.tzz.controller;


import com.tzz.entity.HttpResult;
import com.tzz.entity.UserOrder;
import com.tzz.exception.PreException;
import com.tzz.service.UserOrderService;
import com.tzz.vo.KeyAccountOrderVo;
import com.tzz.vo.UserOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/pre/big/customer")
public class BigCustomerController {
    @Autowired
    UserOrderService userOrderService;

    @PostMapping("/create")
    public <T> HttpResult createOrder(@RequestBody UserOrder userOrder) throws PreException {
        userOrderService.createUserOrder(userOrder);
        return HttpResult.success();
    }

    @PostMapping("/query/all")
    public HttpResult<List<UserOrderVo>> getUserOrderKeyAccountOrder(){
        return HttpResult.success(userOrderService.findAllUserOrderKeyAccountOrder());
    }

    @PostMapping("/sync")
    public <T> HttpResult syncBigCustomOrder(@RequestBody KeyAccountOrderVo keyAccountOrderVo){
        userOrderService.syncKeyAccountOrder(keyAccountOrderVo);
        return HttpResult.success();
    }
}
